/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package fr.castorflex.ohos.verticalviewpager.sample;

import fr.castorflex.ohos.verticalviewpager.VerticalViewPager;
import fr.castorflex.ohos.verticalviewpager.transformer.MathUtils;
import fr.castorflex.ohos.verticalviewpager.transformer.TransformerItem;
import fr.castorflex.ohos.verticalviewpager.transformer.ZoomOutSlideTransformer;
import junit.framework.TestCase;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import org.junit.Test;

/**
 * 测试
 *
 * @author shetaotao
 * @since 2021-04-25
 */
public class VerticalViewPagerTest extends TestCase {
    private static final float VALUE_ONE = 1.0F;
    private static final float VALUE_TWO = 2.0F;

    /**
     * 包名测试
     */
    @Test
    public void testBundleName() {
        final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
        assertEquals("fr.castorflex.ohos.verticalviewpager", actualBundleName);
    }

    /**
     * TransformerItem 测试
     */
    @Test
    public void testTransformerItem() {
        TransformerItem transformerItem = new TransformerItem(ZoomOutSlideTransformer.class);
        assertNotNull(transformerItem);
    }

    /**
     * PageTransformer 测试
     */
    @Test
    public void testPageTransformer() {
        TransformerItem transformerItem = new TransformerItem(ZoomOutSlideTransformer.class);
        VerticalViewPager.PageTransformer pageTransformer = transformerItem.getPageTransformer();
        assertNotNull(pageTransformer);
    }

    /**
     * 浮点减法测试
     */
    @Test
    public void testFloatToSubtract() {
        float subtractValue = MathUtils.floatToSubtract(VALUE_TWO, VALUE_ONE);
        assertEquals(VALUE_ONE, subtractValue);
    }

    /**
     * 浮点加法测试
     */
    @Test
    public void testFloatToAdd() {
        float subtractValue = MathUtils.floatToAdd(VALUE_ONE, VALUE_ONE);
        assertEquals(VALUE_TWO, subtractValue);
    }
}